package com.example.lhh.util;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.nio.file.Paths;


/**
 * mybatis-plus代码生成器
 * author：luoHongHu
 */
public class CodeGenerator {
    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://localhost:3306/inventory_manage_sys?serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&autoReconnect=true", "root", "123456")
                .globalConfig(builder -> builder
                        .author("luoHongHu")
                        .outputDir(Paths.get(System.getProperty("user.dir")) + "/src/main/java")
                        .commentDate("yyyy-MM-dd")
                )
                .packageConfig(builder -> builder
                        .parent("com.example.lhh.purchase")
                        .entity("entity")
                        .mapper("mapper")
                        .service("service")
                        .serviceImpl("service.impl")
                        .controller("controller")
                        .xml("mapper.xml")
                )
                .strategyConfig(builder -> builder
                        .addInclude("lhh_medicine","lhh_supplier","lhh_stock","lhh_purchase_order","lhh_purchase_order_detail")
                        .entityBuilder()
                        .enableLombok()
                )
                .templateEngine(new FreemarkerTemplateEngine())
                .execute();
    }
}
